import java.util.Arrays;
 
public class Demo6703 {

  public static void main(String[] args) {
    //使用自然排序
    Course6703[] courses=getCourses();
   // Arrays.sort(courses);
	Arrays.stream(getCourses()).sorted((c1,c2) -> c1.getTerm().compareToIgnoreCase(c2.getTerm())).forEach(System.out::println);

   // for (Course6703 c : courses) {
    //  System.out.println(c);
   // }
   System.out.println("===========统计功能===========");
		int sum = 0, max = courses[0].getScore(), min = courses[0].getScore();
		for (Course6703 c : courses) {
			sum += c.getScore();
			max = Math.max(c.getScore(), max);
			min = Math.min(c.getScore(), min);

		}
		int average = sum / courses.length;
		System.out.println("平均分：" + average);
		System.out.println("最高分：" + max);
		System.out.println("最低分：" + min);
		
		
		System.out.println("===添加查询功能====");
				for(Course6703 c : courses){
					if(c.getScore() >= 85)
					System.out.println(c);
				}
  }
  

  private static Course6703[] getCourses() {
    //使用数组保存一组对象
    Course6703[] courses=new Course6703[10];
    courses[0]=new Course6703("A001", "C程序设计基础", "1上", 4, 80);
    courses[1]=new Course6703("B002", "Pthon程序基础", "1下", 2, 85);
    courses[2]=new Course6703("A002", "面向对象程序设计", "2上", 3, 78);
    courses[3]=new Course6703("C001", "Java程序高级开发", "3上", 2, 83);
    courses[4]=new Course6703("C002", "软件工程与UML", "3下", 3, 75);
    courses[5]=new Course6703("B001", "操作系统", "2下", 3, 90);
    courses[6]=new Course6703("A003", "数据库原理", "2上", 3, 78);
    courses[7]=new Course6703("B003", "网络基础", "3上", 3, 75);
    courses[8]=new Course6703("0001", "大学英语", "1上", 3, 80);
    courses[9]=new Course6703("0002", "高等数学", "1下", 2, 85);
    return courses;
  }
}
